from Config.Setting import PROXY_GETTER, logger
from IP.check_ip_proxy import check_ip_main
from Server.flask_web import runFlask
from IP.get_ip_proxy import get_ip_proxy_
from apscheduler.schedulers.background import BackgroundScheduler


scheduler = BackgroundScheduler()
scheduler.add_job(check_ip_main,"cron", id=str(1), minute='*/1')
try:
    scheduler.start()
except:
    logger.exception("作业存储器运行失败！")

for p in PROXY_GETTER:
    try:
        scheduler.add_job(eval("get_ip_proxy_."+p),"cron", id=str(2), second='*/10')
        logger.info(f"{p}任务队列开启成功!")
    except:
        logger.exception(f"{p}任务队列开启失败！")
runFlask()
